<template>

  <el-table :data="tableData" class="data_table" style="width: 100%;">
<el-table-column prop="goodId" label="商品编号" width="80">
      <template slot-scope="{row}">
        <span>{{ row.good.goodId }}</span>
      </template>
    </el-table-column>
    <el-table-column prop="name" label="商品名称" width="100">
      <template slot-scope="{row}">
        <span>{{ row.good.goodName }}</span>
      </template>
    </el-table-column>
    <el-table-column prop="goods" label="商品类型" width="100">
      <template slot-scope="{row}">
        <span>{{ row.good.goodType }}</span>
      </template>
    </el-table-column>
    <el-table-column prop="goods" label="商品规格" width="100">
      <template slot-scope="{row}">
        <span>{{ row.good.spec }}</span>
      </template>
    </el-table-column>
    <el-table-column prop="goods" label="商品数量" width="80">
      <template slot-scope="{row}">
        <span>{{ row.goodNumber }}</span>
      </template>
    </el-table-column>
    <el-table-column prop="date" label="保质期" width="250">
      <template slot-scope="{row}">
        <el-date-picker ref="date" type="datetime" v-model="row.good.validDate" readonly />
      </template>
    </el-table-column>
    <el-table-column prop="num" label="购买价格" width="80">
      <template slot-scope="{row}">
        <span>{{ row.price }}</span>
      </template>
    </el-table-column>
    <el-table-column prop="date" label="截至日期" width="250">
      <template slot-scope="{row}">
        <el-date-picker ref="date" type="datetime" v-model="row.end_time" readonly />
      </template>
    </el-table-column>
    <el-table-column prop="price" label="报价单状态" width="150">
      <template slot-scope="{row}">
        <span>{{ row.quotationState.toString() }}</span>
      </template>
    </el-table-column>
    <el-table-column label="Actions" align="center" width="200" class-name="seeMore">
      <template slot-scope="{row}">
        <el-button v-waves class="filter-item" type="primary" :disabled="row.quotationState.toString() == 'QUOTATION_DISPLAY'" @click="deletequo(row)">
          删除
        </el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
  import axios from 'axios'
  import request from '@/utils/request'

  export default {
    name: 'buy',
    data() {
      return {
        storeNumber: '',
        userName: "",
        storeName: '',
        storeLocation: '',
        tableData: []
      }
    },
    mounted(){
      this.init()
    },
    methods: {
      init() {
        this.userName = JSON.parse(sessionStorage.getItem("login_name"))
        this.storeNumber = JSON.parse(sessionStorage.getItem('store')).storeNumber
        this.storeName = JSON.parse(sessionStorage.getItem('store')).storeName
        this.storeLocation = JSON.parse(sessionStorage.getItem('store')).location
        // 初始化 报价数据
        request.get('/quotationService/getStoresQuoOfBuy/'+this.storeNumber + "/" + this.userName).then(request=>{
          var Data=request.data  //PFResponse 类
          if (Data.code == 200){
            this.tableData = Data.data
          }
        })
      },
      deletequo(row){
        request.delete('/quotationService/deleteQuation/'+row.quotationId).then(request =>{
          var Data = request.data
          if(Data.code == 200){
            this.$message.success('删除成功！')
            this.init()
          }
        })
      }
    }
  }
</script>

<style scoped>

</style>
